package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.mapper.OperateLogMapper;
import com.itheima.pojo.OperateLog;
import com.itheima.pojo.PageResult;
import com.itheima.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: zhengsuyang
 * @Desc:
 * @create: 2025-09-14 17:29
 **/
@Service
public class LogServiceImpl implements LogService {
    @Autowired
    private OperateLogMapper operateLogMapper;
    /**
     * 获取日志列表
     *
     * @param page
     * @param pageSize
     * @return
     */
    @Override
    public PageResult<OperateLog> getLogPage(int page, int pageSize) {
        // 设置分页
        PageHelper.startPage(page,pageSize);
        // 执行查询
        List<OperateLog> logList = operateLogMapper.getLogPage(page,pageSize);
        // 封装到
        PageInfo<OperateLog> pageInfo = new PageInfo<>(logList);
        // 返回
        return new PageResult<>(pageInfo.getTotal(),pageInfo.getList());
    }
}
